package com.cqie.secondhandtransaction.controller;

import com.cqie.secondhandtransaction.DTO.AccessDTO;
import com.cqie.secondhandtransaction.DTO.DataList;
import com.cqie.secondhandtransaction.controller.params.ProductTypeParam;
import com.cqie.secondhandtransaction.entity.ProductInfo;
import com.cqie.secondhandtransaction.model.Result;
import com.cqie.secondhandtransaction.service.AccessInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gdy
 * @since 2025-02-10
 */
@RestController
@RequestMapping("/accessInfo")
@Api(value = "评价信息", tags = {"评价信息"})
public class AccessInfoController extends BaseController{

    @Autowired
    private AccessInfoService accessInfoService;

    @PostMapping("/add")
    @ApiOperation(value = "添加评论", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(code = 200, message = "ok", response = Result.class)
    public Result<Void> addAccess(@ModelAttribute @Validated AccessDTO dto,
                                  @RequestParam(value = "pictures", required = false) List<MultipartFile> pictures) {
        accessInfoService.addAccess(dto, pictures);
        return response();
    }

    @GetMapping("/delete")
    @ApiOperation(value = "删除评论", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(code = 200, message = "ok", response = Result.class)
    public Result<Void> deleteAccess(@RequestParam Integer id) {
        accessInfoService.deleteAccess(id);
        return response();
    }

}
